/*
 * Copyright (c) 2011-2014, fortiss GmbH.
 * Licensed under the Apache License, Version 2.0.
 *
 * Use, modification and distribution are subject to the terms specified
 * in the accompanying license file LICENSE.txt located at the root directory
 * of this software distribution. A copy is available at
 * http://chromosome.fortiss.org/.
 *
 * This file is part of CHROMOSOME.
 *
 * $Id: printFunction.c 7805 2014-03-13 09:54:35Z geisinger $
 */

/**
 * \file
 *         Source file for function print in component logger.
 *
 * \author
 *         This file has been generated by the CHROMOSOME Modeling Tool (XMT)
 *         (fortiss GmbH).
 */

/******************************************************************************/
/***   Includes                                                             ***/
/******************************************************************************/
#include "detector/adv/logger/include/printFunction.h"

#include "detector/adv/logger/include/printFunctionWrapper.h"
#include "detector/adv/logger/include/loggerComponent.h"
#include "detector/adv/logger/include/loggerComponentWrapper.h"
#include "detector/adv/logger/include/loggerManifest.h"

#include "xme/core/logUtils.h"

#include "xme/hal/include/mem.h"

// PROTECTED REGION ID(DETECTOR_ADV_LOGGER_PRINTFUNCTION_C_INCLUDES) ENABLED START
#include "xme/core/log.h" //TODO
// PROTECTED REGION END

/******************************************************************************/
/***   Definitions                                                          ***/
/******************************************************************************/

// PROTECTED REGION ID(DETECTOR_ADV_LOGGER_PRINTFUNCTION_C_DEFINITIONS) ENABLED START
// PROTECTED REGION END

/******************************************************************************/
/***   Variables                                                            ***/
/******************************************************************************/

// PROTECTED REGION ID(DETECTOR_ADV_LOGGER_PRINTFUNCTION_C_VARIABLES) ENABLED START
// PROTECTED REGION END

/******************************************************************************/
/***   Prototypes                                                           ***/
/******************************************************************************/

// PROTECTED REGION ID(DETECTOR_ADV_LOGGER_PRINTFUNCTION_C_PROTOTYPES) ENABLED START
// PROTECTED REGION END

/******************************************************************************/
/***   Implementation                                                       ***/
/******************************************************************************/
xme_status_t
detector_adv_logger_printFunction_init
(
    detector_adv_logger_loggerComponent_config_t* const componentConfig
)
{
    // PROTECTED REGION ID(DETECTOR_ADV_LOGGER_PRINTFUNCTION_INITIALIZE_C) ENABLED START
    XME_UNUSED_PARAMETER(componentConfig);

    return XME_STATUS_SUCCESS;
    // PROTECTED REGION END
}

void
detector_adv_logger_printFunction_step
(
    detector_adv_logger_loggerComponent_config_t* const componentConfig
)
{
    xme_status_t status[1];
    
    detector_topic_device_info_t portInfoData; // Required port.
    
    (void)xme_hal_mem_set(&portInfoData, 0u, sizeof(detector_topic_device_info_t));
    
    status[0] = detector_adv_logger_loggerComponentWrapper_readPortInfo(&portInfoData);
    
    {
        // PROTECTED REGION ID(DETECTOR_ADV_LOGGER_PRINTFUNCTION_STEP_C) ENABLED START
        XME_UNUSED_PARAMETER(componentConfig);
        XME_UNUSED_PARAMETER(status);

        XME_LOG(XME_LOG_ALWAYS, "%s: %d\n", portInfoData.name, portInfoData.counter);
        // PROTECTED REGION END
    }
    
    {
        // PROTECTED REGION ID(DETECTOR_ADV_LOGGER_PRINTFUNCTION_STEP_2_C) ENABLED START

        XME_CHECK(XME_STATUS_SUCCESS == status[0], XME_CHECK_RVAL_VOID);

        // PROTECTED REGION END
    }
}

void
detector_adv_logger_printFunction_fini
(
    detector_adv_logger_loggerComponent_config_t* const componentConfig
)
{
    // PROTECTED REGION ID(DETECTOR_ADV_LOGGER_PRINTFUNCTION_TERMINATE_C) ENABLED START
    XME_UNUSED_PARAMETER(componentConfig);
    // PROTECTED REGION END
}

// PROTECTED REGION ID(DETECTOR_ADV_LOGGER_PRINTFUNCTION_IMPLEMENTATION_C) ENABLED START
// PROTECTED REGION END
